{% extends "logged_base.html" %}
{% load tagging_tags%}

{% block _style %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}_styles/smart.css" media="all" />
{% endblock %}

{% block _script %}
<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/chrono.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/smart-input.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/sprint-status.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/planning1/create-history.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}_scripts/sprint/planning1/planning-1.js"></script>
{% endblock %}

{% block body %}

<div id="planning-status">
	<form id="planning-status-form" method="post" action="{% url planning1_status id_sprint %}">
		{% include "planning-status.html" with time=sprint.planning1_time %}
	</form>
</div>

{% include "messages.html" %}

<h1>{{ _('Planning') }} 1</h1>

{% include "smart-input.html" %}

{% include "detailed-history.html" %}

<!-- Historias dentro do sprint -->
<form id="edit-formset-histories" method="post" action="{% url edit_sprint id_sprint %}" >
	{% csrf_token %}
	{{ histories_formset.management_form }}

	<table id="sprint-histories" class="history-board">
		<thead>
			<tr class="title" >
				<td colspan="4">
				<h2>{{_('Sprint histories')}}</h2>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
				<input id="select-all-none" type=CHECKBOX name="select" />
				</td>
				<td colspan="" style="text-align:left;">
				<button type="submit" name="delete-history" title="{{_('Delete from dashboard')}}">
					{{_('Delete')}}
				</button>
				<button type="submit" name="store-history" title="{{_('Remove from sprint and send to release backlog')}}">
					{{_('Store')}}
				</button>
				</td>
				<td>
				<h3>{{_('Estimate')}}</h3>
				</td>
			</tr>
		</thead>

		<tbody>
			{% for history in histories_formset.forms  %}
				{% include "history-table.html" %}
			{% endfor %}
		</tbody>
	</table>
</form>

<!-- **************************************************************************************************************
													RELEASE HISTOTY
*************************************************************************************************************** -->
{% if release_formset.forms %}
<!-- Historias dentro do release -->
<form id="edit-formset-release" method="post" action="{% url edit_release id_sprint %}" >
	{% csrf_token %}
	{{ release_formset.management_form }}

	<table id="release-histories" class="history-board">
		<thead>
			<tr class="title" >
				<td colspan="4">
				<h2>{{_('Release Histories')}}</h2>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
				<input id="select-all-none" type=CHECKBOX name="select" />
				</td>
				<td colspan="" style="text-align:left;">
				<button type="submit" name="delete-history" title="{{_('Delete from dashboard')}}">
					{{_('Delete')}}
				</button>
				<button type="submit" name="promote-history" title="{{_('Send this history to sprint backlog')}}">
					{{_('Promote')}}
				</button>
				</td>
				<td>
				<h3>{{_('Estimate')}}</h3>
				</td>
			</tr>
		</thead>

		<tbody>
			{% for history in release_formset.forms  %}
			<tr>
				<td>
				<!-- Keyboard shortcuts-->
				</td>
				<td class="history-selection">	{{history.check}}</td>
				<td class="edit-history">
				{% tags_for_object history.instance as tag_list %}
				{% for tag in tag_list %}
				<span class="tags">
					<i>{{tag}}</i>
				</span>
				{% endfor %}
				{{history.instance.name}}
				{% if history.instance.description %}
				<i>{{history.instance.description}}</i>
				{% endif %}

				<!-- Edit History Modal -->
				<div id="create-project-modal" class="modal grid_4">
					<div class="title">
						{{_('Edit History')}}
					</div>

					<div class="body">
						<fieldset>
							{{history.id}}

							<dl>
								<dt>
									<label class="form-lbl" for="">
										{{history.name.label}}
									</label>
								</dt>
								<dd>
									{{history.name}}
								</dd>
							</dl>
							<br />

							<dl>
								<dt>
									<label class="form-lbl" for="">
										{{history.description.label}}
									</label>
								</dt>
								<dd>
									{{history.description}}
								</dd>
							</dl>
							<br />

							<dl>
								<dt>
									<label class="form-lbl" for="">
										{{history.tags.label}}
									</label>
								</dt>
								<dd>
									{{history.tags}}
								</dd>
							</dl>
							<br />

							<dl>
								<dt>
									<label class="form-lbl" for="">
										{{history.estimate.label}}
									</label>
								</dt>
								<dd>
									{{history.estimate}}
								</dd>
							</dl>
							<br />
						</fieldset>
						<button type="submit">
							{{_('Adicionar')}}
						</button>
						<button class="cancel-edit-history" >
							{{_('Cancel')}}
						</button>
					</div>
				</div>
				</td>
				<td>
				{% if history.instance.estimate %}
				{{history.instance.estimate}}
				{% else %}
				<a class="estimate-modal" href="#estimate">{{_('Estimate')}}</a>
				<span class="estimate-input">{{history.estimate}}</span>
				{% endif %}
				</td>
			</tr>
			{% endfor %}
		</tbody>
	</table>
</form>
{% endif %}

{% endblock %}

